let datetime ="";
/**
 * @note 加载cimiss地面自动站数据
 * @author 吴义迪
 * @create_time 2017-08-07
 */
function requestDataByParam(id){
	if(Config.layerType1.indexOf(","+id+",") > -1){
		Global.common.micaps3Data = null;
		Global.common.micaps3Id = null;
	}
	
	var showType = $("#tree_li_"+id+"").attr("showtype");
	var flag="";//传入后台标识
	var param="";//映射参数
	var returnColumn="";//返回字段
	var unit = "";	//单位
	var showTypeArray = [];
	
	//选中的要素图层加入到数组中
	if($("#advancedQuery_meteoShowType_"+id+">span[param='point']").attr("flag") == "1" ||
	   $("#advancedQuery_meteoShowType_"+id+">span[param='label']").attr("flag") == "1"){
		showTypeArray.push("point");
	}
	if($("#advancedQuery_meteoShowType_"+id+">span[param='isoGeo']").attr("flag") == "1"){
		showTypeArray.push("isoGeo");
	}
	//取时间轴日期
	var year = $("#timeAxis_input").val().substring(0,4);
	var month = $("#timeAxis_input").val().substring(5,7);
	var day = $("#timeAxis_input").val().substring(8,10)-1;
	var tendays = $("#timeAxis_input").val().substring(8,10);
	var hour = $("#timeAxis_input").val().substring(11,13);
	var date=new Date(parseInt(year),parseInt(month)-1,parseInt(day),parseInt(hour),0,0);
	// if(Global.common.timeAxisType == "HOUR"){
	// 	date.setHours(date.getHours()-8); 小时的计算
	// }
	// year=date.getFullYear();
	// month=date.getMonth()+1;
	// if(month<10){
	// 	month="0"+month+"";
	// }
	// //day=date.getDate();
	// if(day<10){
	// 	day="0"+day+"";
	// }
	// hour=date.getHours();
	// if(hour<10){
	// 	hour="0"+hour+"";
	// }
	if(Global.common.timeAxisType == "YEAR"){
		datetime = year;
	}else if(Global.common.timeAxisType == "MONTH"){
		datetime = year + month;
	}else if(Global.common.timeAxisType == "TENDAYS"){
		datetime = year + month + tendays;
	}else if(Global.common.timeAxisType == "DAY"){
		 if(day<10){
		 	day="0"+day+"";
		 }
		datetime = year + month + day;
	}else if(Global.common.timeAxisType == "YUBAO"){
		datetime = year + month + day;
		var dates= new Date();
		var years = dates.getFullYear();
		var months = dates.getMonth()+1;
		var days = dates.getDate()
		if(months<10){
			months = "0"+months;
		}
		if(days<10){
			days = "0"+days;
		}
		datetime = ""+years+""+months+""+days;
	}
	
	for(var i=0;i<cimissArr.length;i++){
		var cacheObj=cimissArr[i];
		if(cacheObj.name == Global.common.param1){
			flag=cimissArr[i].flag;
			param=cimissArr[i].param;
			returnColumn=cimissArr[i].returnColumn;
			unit = cimissArr[i].unit == null ? "" : cimissArr[i].unit;
			break;
		}
	}
	var paramObj={};
	var paramArr=param.split(',');
	for(var i=0;i<paramArr.length;i++){
		if(paramArr[i]=="startDate"||paramArr[i]=="endDate"){
			if(showType == "normalmeteo"){
				if(Global.common.param1.split(",")[1].toLowerCase()=="interval"){//任意时段
					var star=$("#timeAreaStar").val();
						var end=$("#timeAreaEnd").val();
						if((Config.layerType1.indexOf(","+id+",") >= 0 && Global.common.param1.split(",")[1] == "INTERVAL")){
							star=TimeBJToTimeWd(star);
							end=TimeBJToTimeWd(end);
						}
						
						if(star==""){
							star=($("#normalYear").val()-1)
							+$("#normalMonth").val()
							+$("#normalDay").val()
							+$("#normalHour").val()+"0000";
						}
						if(end==""){
							end=$("#normalYear").val()
							+$("#normalMonth").val()
							+$("#normalDay").val()
							+$("#normalHour").val()+"0000";
						}
					if(paramArr[i]=="startDate"){
						paramObj[paramArr[i]]=star;
					}else if(paramArr[i]=="endDate"){
						paramObj[paramArr[i]]=end;
					}
				}else{//常规查询
					if(Global.common.param1.split(",")[1] == "HOUR"){
						paramObj[paramArr[i]]=year+""+month+""+day+""+hour+"0000";
					}else if(Global.common.param1.split(",")[1] == "DAY"){
						paramObj[paramArr[i]]=year+""+month+""+day+"000000";
					}else if(Global.common.param1.split(",")[1] == "MON"){
						paramObj[paramArr[i]]=year+""+month+"01000000";
					}else if(Global.common.param1.split(",")[1] == "YEA"){
						paramObj[paramArr[i]]=year+"0101000000";
					}
				}
			}
		}else if(paramArr[i] == "areaCode"){
			paramObj[paramArr[i]] = Global.common.areaCode;
		}else if(paramArr[i] == "suffix"){
			var stationTypeArray = [];
			var stationTypeFlag = false;
			$("#advancedQuery_stationShowType_"+id+">span[flag='1']").each(function(){
				stationTypeArray.push(this.attributes.param.nodeValue);
			});
			Config.geojson=1;
			for(var p=0; p<stationTypeArray.length; p++){
				if(stationTypeArray[p] == "station_qy"){
					paramObj[paramArr[i]] = "";
					stationTypeFlag = true;
					break;
				}
			}
			if(stationTypeFlag == false){
				paramObj[paramArr[i]] = "_auto";
			}
		}
	}
	var paramStr=JSON.stringify(paramObj);
	if(showTypeArray.length > 0){
		for(var p=0; p<showTypeArray.length; p++){
			var showTypeStr = showTypeArray[p];
			requestDataByParamAjax(flag,paramStr,showTypeStr,id,returnColumn,showType,unit);
		}
	}else if($("#advancedQuery_meteoShowType_"+id+"").length <= 0){
		requestDataByParamAjax(flag,paramStr,"point",id,returnColumn,showType,unit);
	}
}

/**
 * @note cimiss地面自动站数据ajax请求	
 * @author 吴义迪
 * @create_time 2017-08-07
 */
function requestDataByParamAjax(flag,paramStr,showTypeStr,id,returnColumn,showType,unit){
	var funcName="requestDataByParam.do";
	if(Config.layerType9.indexOf(","+id+",") >= 0){ //常规要素
		var timetype = Global.common.param1.split(",")[0];
		var elementtype = Global.common.param1.split(",")[1];		
		var time = datetime;
		if(localStorage.getItem("areacode") !== null){ 
			var cityname = codeToName(localStorage.getItem("areacode"));
		} else {
			var cityname = "chongqingshi";
		}
		var jsonurl = "http://183.230.183.18:8088/pisajson/products/dap/observe/"+ cityname +"/normalElement/5/";
		if( elementtype.toLowerCase() == "avgtemp" || elementtype.toLowerCase() == "maxtemp" || elementtype.toLowerCase() == "mintemp" ){ //温度 拼接路径
			jsonurl += "temp/"+ elementtype + "/"+timetype  + "/"+ datetime + "_" + cityname + "__normalElement_5_" + "temp_"+ elementtype +"_" + timetype + ".json";
		} else if(  elementtype == "precipitation" ){ //降水 拼接路径
			jsonurl += "precipitation/20To20Precipitation/"+ timetype + "/"+ datetime + "_" + cityname + "__normalElement_5_" + "precipitation_20To20Precipitation_" + timetype + ".json";
		} else if(  elementtype == "sun" ){ //日照 拼接路径
			jsonurl += "sun/sunHours/"+ timetype + "/"+ datetime + "_" + cityname + "__normalElement_5_" + "sun_sunHours_" + timetype + ".json";
		} else if(  elementtype.toLowerCase().indexOf("soiltemp") >= 0  ){ //土壤湿度 拼接路径
			jsonurl += "soilTemp/"+ elementtype + "/" + timetype + "/"+ datetime + "_" + cityname + "__normalElement_5_" + "soilTemp_" + elementtype + "_" + timetype + ".json";
		} else if(  elementtype.toLowerCase().indexOf("tamp") >= 0  ){ //墒情 拼接路径
				jsonurl += "soilTamp/"+ elementtype + "/" + timetype + "/"+ datetime + "_" + cityname + "__normalElement_5_" + "soilTamp_" + elementtype + "_" + timetype + ".json";
		} else if(  elementtype.toLowerCase().indexOf("acttemp") >= 0  ){ //积温 拼接路径
			jsonurl += "actTemp/" + timetype + "/"+ datetime + "_" + cityname + "__normalElement_5_" + "actTemp" + "_" + timetype + ".json";
		}
		console.log(jsonurl);
	} else if(Config.layerTypeJ.indexOf(","+id+",") >= 0){//气候区划
		if(localStorage.getItem("areacode") !== null){ 
			var cityname = codeToName(localStorage.getItem("areacode"));
		} else {
			var cityname = "chongqingshi";
		}
		var type = localStorage.getItem("type");
		var name = localStorage.getItem("name");
		var jsonurl = "http://183.230.183.18:8088/pisajson/products/"+ type +"/"+ name +"_" + cityname + ".json";
		console.log(jsonurl);
	} else if(Config.layerTypeYubao.indexOf(","+id+",") >= 0){ //预警预报
		var timetype = Global.common.param1.split(",")[0];
		var elementtype = Global.common.param1.split(",")[1];
		var time = datetime;
		var jsonurl = "http://183.230.183.18:8088/pisajson/products/dap/forecast/"+ elementtype +"/"+ time +"/" + time + timetype +"_" + $("#timeAxis_input").val() +".json";
		console.log(jsonurl);
	}	
	$.ajax({
		url: jsonurl,
		type: "get",
		dataType: "json",
		async: false,
		success:function(result){
			var jsonStr = result.data;
			var status = result.status;
			if(status == 0){
				var resData = JSON.parse(jsonStr);
				showPointDataByMeteo(id, resData, "micaps3", returnColumn,showTypeStr,unit);
			}else{
				if(Config.layerType9.indexOf(","+id+",") >= 0 && showTypeStr == "point"){
					var layers = Global.common.map.getLayersByName(Config.layerType9Name[0]);
					if(layers.length > 0){
						layers[0].removeAllFeatures();
					}
				}else if(Config.layerType9.indexOf(","+id+",") >= 0 && showTypeStr == "isoGeo"){					
					var layers = Global.common.map.getLayersByName(Config.layerType9Name[1]);
					if(layers.length > 0){
						layers[0].removeAllFeatures();
					}
					getgeoJsonByJson(id, result);
				}else if(Config.layerTypeJ.indexOf(","+id+",") >= 0 && showTypeStr == "point"){					
					var layers = Global.common.map.getLayersByName(Config.layerType9Name[1]);
					if(layers.length > 0){
						layers[0].removeAllFeatures();
					}
					showisGeo(id, result);
				}else if(Config.layerTypeYubao.indexOf(","+id+",") >= 0 && showTypeStr == "isoGeo"){					
					var layers = Global.common.map.getLayersByName(Config.layerType9Name[1]);
					if(layers.length > 0){
						layers[0].removeAllFeatures();
					}
					getgeoJsonByJson(id, result);
				}
				if(showTypeStr == "point"){
					showPromptMessage("所查询时次没有数据！");
					$("#map_table").hide();
				}else{
					showPromptMessage("所查询时次没有色斑图！");
				}
			}
		},
		error: function() {			
			Global.common.map.getLayersByName("isoGeoVector")[0].removeAllFeatures();			
		}
	});
}

/**
 * @note 根据数据类型分发请求方法
 * @author 吴义迪
 * @create_time 2017-08-07
 */
function showPointDataByMeteo(id,resData,type,returnColumn,showType,unit){
	if(showType=="isoGeo"){//色斑图
		getgeoJsonByJson(id,resData);
//		showIsoGeo(id,resData);
	}else{
		if(type=="micaps3"){//点
			showMicaps3(id,resData,returnColumn,unit);
		}
	}
}

/**
 * @note 展示色斑图
 * @author 吴义迪
 * @create_time 2017-11-03
 */
function showIsoGeo(id,data){
	var layers = Global.common.map.getLayersByName(Config.layerType9Name[1]);
	if(layers.length > 0){
		layers[0].removeAllFeatures();
	}else{
		layers.push(new SuperMap.Layer.Vector(Config.layerType9Name[1]));
		Global.common.map.addLayer(layers[0]);
		layerIndexControl(layers[0]);
	}
	if(data!=null&&data!=''){
		var vArray = new Array();
		$.each(data.features,function(idx1,regionItem){
//			warnMessageRemoveByClass("NoDateMessageDiv");
			var region;
			var mulregions=new Array();
			for(var k=0;k<regionItem.geometry.coordinates.length;k++){
				var curdata0=regionItem.geometry.coordinates[k];
				var points2 = new Array();
				for(var j=0;j<curdata0.length;j++){
					points2[j] = new SuperMap.Geometry.Point(curdata0[j][0],curdata0[j][1]);
				}
				var line2 = new SuperMap.Geometry.LinearRing(points2);
				mulregions[k]=line2;
			}
			region = new SuperMap.Geometry.Polygon(mulregions);
			var regionVector= new SuperMap.Feature.Vector(region);
			var colors=regionItem.properties.color.split(",");
			if(colors[0]=="255"&&colors[1]=="255"&&colors[2]=="255"){
				regionVector.style={
					fillColor:"rgb("+colors[0]+","+colors[1]+","+colors[2]+")",
					strokeWidth:0
				};
			}else{
				regionVector.style={
					fillColor:"rgb("+colors[0]+","+colors[1]+","+colors[2]+")",
					strokeWidth:0
				};
			}
			vArray.push(regionVector);
		});
		layers[0].addFeatures(vArray);
		if(ifCloseRequestMessage){
			closePromptMessage();
		}
	}else{
		showPromptMessage("所查询时次没有色斑图！");
	}
}

/**
 * @note 展示色斑图(气象区划)
 * @author 陈靖宇
 * @create_time 2017-11-03
 */
function showisGeo(id,data){
	var layers = Global.common.map.getLayersByName(Config.layerType9Name[1]);
	Global.common.kjTitle = {"text": data.name};
	if(layers.length > 0){
		layers[0].removeAllFeatures();
	}else{
		layers.push(new SuperMap.Layer.Vector(Config.layerType9Name[1]));
		Global.common.map.addLayer(layers[0]);
		layerIndexControl(layers[0]);
	}
	if(data!=null&&data!=''){
		var vArray = new Array();
		$.each(data.features,function(idx1,regionItem){
//			warnMessageRemoveByClass("NoDateMessageDiv");
			var region;
			var mulregions=new Array();
			for(var k=0;k<regionItem.geometry.coordinates.length;k++){
				var curdata0=regionItem.geometry.coordinates[k];
				var points2 = new Array();
				for(var j=0;j<curdata0.length;j++){
					points2[j] = new SuperMap.Geometry.Point(curdata0[j][0],curdata0[j][1]);
				}
				var line2 = new SuperMap.Geometry.LinearRing(points2);
				mulregions[k]=line2;
			}
			region = new SuperMap.Geometry.Polygon(mulregions);
			var regionVector= new SuperMap.Feature.Vector(region);
			var colors=regionItem.properties.color.split(",");
			if(colors[0]=="255"&&colors[1]=="255"&&colors[2]=="255"){
				regionVector.style={
					fillColor:"rgb("+colors[0]+","+colors[1]+","+colors[2]+")",
					strokeWidth:0
				};
			}else{
				regionVector.style={
					fillColor:"rgb("+colors[0]+","+colors[1]+","+colors[2]+")",
					strokeWidth:0
				};
			}
			vArray.push(regionVector);
		});
		layers[0].addFeatures(vArray);
		// if(ifCloseRequestMessage){
		// 	closePromptMessage();
		// }
	}else{
		showPromptMessage("所查询时次没有色斑图！");
	}
}

function getgeoJsonByJson(id, data){
	var layers = Global.common.map.getLayersByName(Config.layerType9Name[1]); 
	Global.common.kjTitle = {"text": data[0].Metadata.MainTitle};
	if(layers.length > 0){
		layers[0].removeAllFeatures();
	}else{
		layers.push(new SuperMap.Layer.Vector(Config.layerType9Name[1]));
		Global.common.map.addLayer(layers[0]);
		layerIndexControl(layers[0]);
	}
			if(data!=null&&data!=''){
				var vArray = new Array();
				$.each(data[2].features,function(idx1,regionItem){
					var region;
					var mulregions=new Array();
					for(var i=0;i<regionItem.geometry.coordinates.length;i++){
						for(var k=0;k<regionItem.geometry.coordinates[i].length;k++){
							var curdata0=regionItem.geometry.coordinates[i][k];
							var points2 = new Array();
							for(var j=0;j<curdata0.length;j++){
								//边界点
								points2[j] = new SuperMap.Geometry.Point(curdata0[j][0],curdata0[j][1]);
								
							}
							//点划线
							var line2 = new SuperMap.Geometry.LinearRing(points2);
							mulregions[k]=line2;
						}
						//用所有的线生成普通岛洞图
						region = new SuperMap.Geometry.Polygon(mulregions);
						var regionVector= new SuperMap.Feature.Vector(region);
						var MGMinValue=regionItem.properties.MGMinValue;
						var MGMaxValue=regionItem.properties.MGMaxValue;
						//给岛洞填色
						if(MGMinValue<=-90){
							MGMinValue=MGMaxValue;
						}
						for(var l=data[1].items.length-1;l>=0;l--){
							if(MGMinValue>=data[1].items[l].Value){
								regionVector.style={
										fillColor:data[1].items[l].FillStyle.ForeColor,
										fillOpacity:1,
										strokeWidth:0
								};
								break;
							}
						}
						vArray.push(regionVector);
					}
				});
				layers[0].addFeatures(vArray);
				closePromptMessage();
			}else{
				showPromptMessage("所查询时次没有色斑图！");
			}
}

/**
 * @note 展示micaps3类点数据
 * @author 吴义迪
 * @create_time 2017-08-07
 */
function showMicaps3(id,resData,returnColumn,unit){
	if(parseInt(resData.rowCount)>0){
		var returnColumnArr=returnColumn.split(",");
		var columnObj={};
		for(var i=0;i<returnColumnArr.length;i++){
			columnObj["column"+i]=returnColumnArr[i];
		}
		
		var pointFillColor;
		var legendLevels = null;
		var legendColors = null;
		var legendFlag = $("#tree_ul_"+id+"").attr("levels");
		if(legendFlag != "-1"){
			legendLevels = $("#tree_ul_"+id).attr("levels").split(",");
			legendColors = $("#tree_ul_"+id).attr("colors").split(";");
		}else{
			pointFillColor = "#FF0000";
		}
		var layers = Global.common.map.getLayersByName(Config.layerType9Name[0]);
		var layers1 = Global.common.map.getLayersByName(Config.layerType9Name[1]);
		var opacity = parseInt($("#tree_li_"+id+"").attr("opacity"));
		if(layers.length > 0){
			layers[0].removeAllFeatures();
		}else{
			layers.push(new SuperMap.Layer.Vector(Config.layerType9Name[0]));
			Global.common.map.addLayer(layers[0]);
			//设置透明度
			layers[0].setOpacity(opacity * 0.01);
			Global.common.selectFeatureLayers.push(layers[0]);
			Global.common.selectFeature.setLayer(Global.common.selectFeatureLayers);
		}
		if(layers1.length > 0 && $("#advancedQuery_meteoShowType_"+id+">span[param="+Config[id].meteoParam[2]+"]").attr("flag") == "0"){
			layers1[0].removeAllFeatures();
		}else if(layers1.length > 0){
			//设置透明度
			layers1[0].setOpacity(opacity * 0.01);
		}
		var fs = [];
		var stationTypeArray = $("#advancedQuery_stationShowType_"+id+">span[flag=1]");
		var stationParamArray = [];
		for(var i=0; i<stationTypeArray.length; i++){
			stationParamArray.push(stationTypeArray[i].attributes.param.nodeValue);
		}
		var fontOpacity;
		var pointRadius;
		if($("#advancedQuery_meteoShowType_"+id+">span[param='label']").attr("flag") == "1"){
			fontOpacity = "1";
		}else{
			fontOpacity = "0";
		}
		if($("#advancedQuery_meteoShowType_"+id+">span[param='point']").attr("flag") == "1"){
			pointRadius = "5";
		}else{
			pointRadius = "0";
		}
		
		var windImgFlag = false;
		if(Global.common.windImgStr.indexOf(","+columnObj["column4"]+",") > -1){
			windImgFlag = true;
		}
		for(var i=0;i<resData.DS.length;i++){
			pointFillColor = "RGBA(255,0,0,1)";
			var obj=resData.DS[i];
			var labelInfo = "";
			var station= new SuperMap.Geometry.Point(obj[columnObj["column2"]],obj[columnObj["column3"]]);
	    	var stationFeatureVector = new SuperMap.Feature.Vector(station);
	    	//缺测值匹配
	    	var missingFlag = false;
			if(obj[columnObj["column4"]] == "" || (!isNaN(obj[columnObj["column4"]]) && parseInt(obj[columnObj["column4"]]) > 900000)){
				pointFillColor = "#808080";
				missingFlag = true;
			}
	    	if(legendFlag != "-1"){
	    		if(missingFlag == false){
	    			for ( var k = 0; k < legendColors.length; k++) {
			    		if (parseFloat(obj[columnObj["column4"]]) >= parseFloat(legendLevels[k].split("~")[0])
								&& parseFloat(obj[columnObj["column4"]]) < parseFloat(legendLevels[k].split("~")[1])) {
		    				pointFillColor = legendColors[k];
							break;
						}
					}
	    		}
	    	}
	    	
	    	//判断当前站点类型
	    	var stationType;
	    	var stationDiaplay = "";
	    	if(resData.DS[i][columnObj["column1"]]==undefined){
	    		continue;
	    	}else if(resData.DS[i]["Station_levl"] == "11" || resData.DS[i]["Station_levl"] == "12" || resData.DS[i]["Station_levl"] == "13"){
	    		stationType = "station_gj";
	    	}else{
	    		stationType = "station_qy";
	    	}
	    	
	    	if(stationParamArray.length > 0){
	    		for(var p=0; p<stationParamArray.length; p++){
		    		if(stationType == stationParamArray[p]){
		    			break;
		    		}
		    		if(p == stationParamArray.length - 1){
		    			stationDiaplay = "none";
		    		}
		    	}
	    	}else{
	    		stationDiaplay = "none";
	    	}
	    	stationFeatureVector.info={};
	    	stationFeatureVector.info.layerId = id;
	    	stationFeatureVector.info.returnColumnArr = returnColumnArr;
	    	stationFeatureVector.info.unit = unit;
	    	stationFeatureVector.info.stationType = stationType;
	    	for(var p=0; p<returnColumnArr.length; p++){
    			if(p>3 && missingFlag == true){
    				stationFeatureVector.info[columnObj["column"+p]]="缺测";
    			}else{
    				stationFeatureVector.info[columnObj["column"+p]]=obj[columnObj["column"+p]];
    			}
	    	}
	    	var fontColor = "#444";
	    	if(Global.common.layer2 != null && !Global.common.layer1.getVisibility() && Global.common.layer2.getVisibility()){
	    		fontColor = "#efefef";
	    	}
	    	
	    	//降水特殊处理，当为0值时，标签不显示
	    	if(Global.common.param1.split(",")[0] == "PREP" && obj[columnObj["column4"]] == "0"){
	    		obj[columnObj["column4"]] = "";
	    	}
	    	
	    	if(missingFlag == false && windImgFlag == true){
	    		//根据风速风向返回不同图片
	    		var imgUrl=getImgUrlByDM(obj[columnObj["column4"]]);
	    		stationFeatureVector.style = {
						graphic: true,
						externalGraphic: imgUrl,
						rotation:obj[columnObj["column5"]],
						graphicWidth: 18,
						graphicHeight: 30,
						fontColor:fontColor,
			        	fontWeight:"bold",
			    		fontFamily:"微软雅黑",
						fontSize: "13px",
			    		fontStyle:"italic",
			    		labelSelect:"true",
			    		labelYOffset:"15",
			    		fontOpacity: fontOpacity,
			    		display: stationDiaplay,
			    		label:missingFlag == false ? obj[columnObj["column4"]]+"" : ""
				};
	    	}else if(missingFlag == false && (Global.common.param1.split(",")[2] == "WEP_Now" || Global.common.param1.split(",")[2] == "WEP_Past_1" || Global.common.param1.split(",")[2] == "WEP_Past_2")){
	    		var imgUrl;
    			if($("#normalHour").val() > 18 || $("#normalHour").val() < 7){
	    			imgUrl = "images/weather/" + "n" + (obj[columnObj["column4"]] < 10 ? "0" + obj[columnObj["column4"]] : obj[columnObj["column4"]]) + ".gif";
	    		}else{
	    			imgUrl = "images/weather/" + "d" + (obj[columnObj["column4"]] < 10 ? "0" + obj[columnObj["column4"]] : obj[columnObj["column4"]]) + ".gif";
	    		}
	    		stationFeatureVector.style={
					graphic: true,
					externalGraphic: imgUrl,
					graphicWidth: 24,
					graphicHeight: 18	
	    		};
	    	}else{
	    		stationFeatureVector.style={
	        	fillColor:pointFillColor,
	        	strokeColor:"black",
	        	strokeWidth: 1,
	        	pointRadius:pointRadius,
	        	fontColor:fontColor,
	        	fontWeight:"bold",
	    		fontFamily:"微软雅黑",
	    		fontSize: "13px",
	    		fontStyle:"italic",
	    		labelSelect:"true",
	    		labelYOffset:"15",
	    		fontOpacity: fontOpacity,
	    		display: stationDiaplay,
	    		label:missingFlag == false ?obj[columnObj["column4"]]+labelInfo : ""
	        	};
	    	}
	    	fs.push(stationFeatureVector);
		}
		layers[0].addFeatures(fs);
	}else{//无数据处理
		showPromptMessage("所查询时次没有数据！");
	}
}

/**
 * @note 请求cimiss雷电数据
 * @param id：图层id
 * @author 吴义迪
 * @create_time 2017-06-30
 */
function requestCimissLightning(id){
	var flag="";//传入后台标识
	var param="";//映射参数
	var returnColumn="";//返回字段
	var star="";
	var end="";
	for(var i=0;i<cimissArr.length;i++){
		var cacheObj=cimissArr[i];
		if( cacheObj.name == "light"){
			flag=cimissArr[i].flag;
			param=cimissArr[i].param;
			returnColumn=cimissArr[i].returnColumn;
			unit = cimissArr[i].unit == null ? "" : cimissArr[i].unit;
			break;
		}
	}
	var paramObj={};
	var paramArr=param.split(',');
	for(var i=0;i<paramArr.length;i++){
		if(paramArr[i]=="startDate"){
			var starDate = new Date();
			var year = parseInt($("#beginTime_input").val().substring(0,4));
			var month = parseInt($("#beginTime_input").val().substring(5,7))-1;
			var date = parseInt($("#beginTime_input").val().substring(8,10));
			var hour = parseInt($("#beginTime_input").val().substring(11,13));
			var min = parseInt($("#beginTime_input").val().substring(14,16));
			var sec = parseInt($("#beginTime_input").val().substring(17,19));
			starDate.setFullYear(year, month, date);
			starDate.setHours(hour, min, sec);
			starDate.setHours(starDate.getHours()-8);
			star = timeFormat2(starDate);
			paramObj[paramArr[i]]=star;
		}else if(paramArr[i]=="endDate"){
			var endDate = new Date();
			var year = parseInt($("#endTime_input").val().substring(0,4));
			var month = parseInt($("#endTime_input").val().substring(5,7))-1;
			var date = parseInt($("#endTime_input").val().substring(8,10));
			var hour = parseInt($("#endTime_input").val().substring(11,13));
			var min = parseInt($("#endTime_input").val().substring(14,16));
			var sec = parseInt($("#endTime_input").val().substring(17,19));
			endDate.setFullYear(year, month, date);
			endDate.setHours(hour, min, sec);
			endDate.setHours(endDate.getHours()-8);
			end = timeFormat2(endDate);
			paramObj[paramArr[i]]=end;
		}else if(paramArr[i] == "minLon"){
			paramObj[paramArr[i]] = Global.common.minLon + "";
		}else if(paramArr[i] == "minLat"){
			paramObj[paramArr[i]] = Global.common.minLat + "";
		}else if(paramArr[i] == "maxLon"){
			paramObj[paramArr[i]] = Global.common.maxLon + "";
		}else if(paramArr[i] == "maxLat"){
			paramObj[paramArr[i]] = Global.common.maxLat + "";
		}
	}
	var paramStr=JSON.stringify(paramObj);
	requestDataByParamAjaxLightning(flag,paramStr,"point",id,returnColumn);
}

/**
 * @note 请求cimiss雷电数据ajax
 * @param id：图层id
 * @author 吴义迪
 * @create_time 2017-06-30
 */
function requestDataByParamAjaxLightning(flag,paramStr,showTypeStr,id,returnColumn){
	$.ajax({
		url:Global.common.ajaxPath+"/cimiss/requestDataByParam.do",
		type: "post",
		data:{"flag":flag,"paramJson":paramStr,"type":showTypeStr},
		dataType: "json",
		scriptCharset:'utf-8',
		success:function(result){
			var jsonStr = result.data;
			var status = result.status;
			if(status == 0){
				var resData = eval('(' + jsonStr + ')');
				showLightningLayer(id,resData,returnColumn);
			}else{
				loadingFunc(id, false);
			}
		}
	});
}

/**
 * @note 展示闪电图层
 * @param id：图层id
 * @author 吴义迪
 * @create_time 2017-06-30
 */
function showLightningLayer(id,resData,returnColumn){
	if(parseInt(resData.rowCount)>0){
		var returnColumnArr=returnColumn.split(",");
		var columnObj={};
		for(var i=0;i<returnColumnArr.length;i++){
			columnObj["column"+i]=returnColumnArr[i];
		}
		var layers = Global.common.map.getLayersByName("layer_"+id+"");
		if(layers.length > 0){
			layers[0].removeAllFeatures();
		}else{
			layers.push(new SuperMap.Layer.Vector("layer_"+id+""));
			Global.common.map.addLayer(layers[0]);
			Global.common.selectFeatureLayers.push(layers[0]);
			Global.common.selectFeature.setLayer(Global.common.selectFeatureLayers);
			refreshSelectCluster();
		}
		var fs = [];
		for(var i=0;i<resData.DS.length;i++){
			var obj=resData.DS[i];
			if(obj[columnObj["column8"]] != "" && obj[columnObj["column8"]] != "内蒙古自治区"){
				continue;
			}
			var station= new SuperMap.Geometry.Point(obj[columnObj["column1"]],obj[columnObj["column2"]]).transform("EPSG:"+Global.transform.source+"","EPSG:"+Global.transform.dest+"");
	    	var stationFeatureVector = new SuperMap.Feature.Vector(station);
	    	stationFeatureVector.info = {};
	    	stationFeatureVector.info.layerId = id;
	    	for(var p=0; p<returnColumnArr.length; p++){
	    		stationFeatureVector.info[columnObj["column"+p]]=obj[columnObj["column"+p]];
	    	}
	    	var imgUrl = "";
	    	if(Number(obj[columnObj["column4"]]) > 0){
	    		imgUrl = "resources/images/lightning_2.png";
	    	}else{
	    		imgUrl = "resources/images/lightning_1.png";
	    	}
    		stationFeatureVector.style={
				graphic: true,
				externalGraphic: imgUrl,
				graphicWidth: 16,
				graphicHeight: 16	
    		};
	    	fs.push(stationFeatureVector);
		}
		layers[0].addFeatures(fs);
	}else{//无数据处理
		
	}
	loadingFunc(id, false);
}

function getImgUrlByDM(data){
	var imgUrl="";
	var returnData="01";
	if(data>999){
		returnData="qc";	
	}else if(data>24.5){
		returnData="10";
	}else if(data>20.8&&data<=24.5){
		returnData="09";
	}else if(data>17.2&&data<=20.8){
		returnData="08";
	}else if(data>13.9&&data<=17.2){
		returnData="07";
	}else if(data>10.8&&data<=13.9){
		returnData="06";
	}else if(data>8.0&&data<=10.8){
		returnData="05";
	}else if(data>5.5&&data<=8.0){
		returnData="04";
	}else if(data>3.4&&data<=5.5){
		returnData="03";
	}else if(data>1.6&&data<=3.4){
		returnData="02";
	}else if(data>0.3&&data<=1.6){
		returnData="01";
	}else{
		returnData="00";
	}
	//注：标准为是指平地上离地10米处的风速值。http://baike.baidu.com/link?url=aWTaRBmK-pFTTY6A4YIW9hm7KaQWwRFIySWkoWvK0W18mN_qz4n0UmcgsksJXi_vsvB4jTl9GuuJyykjFFJJ45i6f_53n0nQqHjmyD5sPZnqq42Cds6GgtdT19YHBPPe&qq-pf-to=pcqq.c2c
	return "resources/images/winddm/wind"+returnData+".png";
}

/**
 * @note 显示提示信息
 * @author 吴义迪
 * @create_time 2017-08-07
 */
function showPromptMessage(){
	
}

/**
 * @note 关闭提示信息
 * @author 吴义迪
 * @create_time 2017-08-07
 */
function closePromptMessage(){
	
}

/**
 * @note 地面填图请求数据
 * @author 吴义迪
 * @create_time 2018-01-16
 */
function requestSuperpositionDataByParam(id){
	loadingFunc(id, true);
	//取时间轴日期
	var year = $("#timeAxis_input").val().substring(0,4);
	var month = $("#timeAxis_input").val().substring(5,7);
	var day = $("#timeAxis_input").val().substring(8,10);
	var hour = $("#timeAxis_input").val().substring(11,13);
	var date=new Date(parseInt(year),parseInt(month)-1,parseInt(day),parseInt(hour),0,0);
	if(Global.common.timeAxisType == "HOUR"){
		date.setHours(date.getHours()-8);
	}
	year=date.getFullYear();
	month=date.getMonth()+1;
	if(month<10){
		month="0"+month+"";
	}
	day=date.getDate();
	if(day<10){
		day="0"+day+"";
	}
	hour=date.getHours();
	if(hour<10){
		hour="0"+hour+"";
	}
	
	var layerType10FlagArray = [];
	var superpositionLabelX = [];
	var superpositionLabelY = [];
	var superpositionLegend = [];
	var superpositionLabelAlign = [];
	$("#advancedQuery_type_"+id+">span[flag='1']").each(function(){
		if($(this).attr("value") != "" && $(this).attr("value") != undefined){
			var value = $(this).attr("value").split(";");
			for(var i=0; i<value.length; i++){
				var value1 = value[i].split(",");
				layerType10FlagArray.push(value1[0]);
				superpositionLabelX.push(value1[1]);
				superpositionLabelY.push(value1[2]);
				superpositionLegend.push(value1[3]);
				superpositionLabelAlign.push(value1[4]);
			}
		}
	});
	var flag="";//传入后台标识
	var param="";//映射参数
	var returnColumn="";//返回字段
	for(var i=0;i<cimissArr.length;i++){
		var cacheObj=cimissArr[i];
		if(cacheObj.name == "micaps1_data"){
			flag=cimissArr[i].flag;
			param=cimissArr[i].param;
			returnColumn=cimissArr[i].returnColumn;
			break;
		}
	}
	var paramObj={};
	var paramArr=param.split(',');
	for(var i=0;i<paramArr.length;i++){
		if(paramArr[i]=="startDate"||paramArr[i]=="endDate"){
			paramObj[paramArr[i]]=year+""+month+""+day+""+hour+"0000";
		}else if(paramArr[i] == "areaCode"){
			paramObj[paramArr[i]] = Global.common.areaCode;
		}
	}
	var paramStr=JSON.stringify(paramObj);
	requestSuperpositionDataByParamAjax(flag,paramStr,id,returnColumn,layerType10FlagArray,superpositionLabelX,superpositionLabelY,superpositionLegend,superpositionLabelAlign);
}

/**
 * @note 地面填图ajax
 * @author 吴义迪
 * @create_time 2018-01-16
 */
var whole_resData = null;
function requestSuperpositionDataByParamAjax(flag,paramStr,id,returnColumn,superpositionFlag,labelX,labelY,color,labelAlign){
	$.ajax({
		url:Global.common.ajaxPath+"/cimiss/requestDataByParam.do",
		type: "post",
		data:{"flag":flag,"paramJson":paramStr,"type":"point"},
		dataType: "json",
		success:function(result){
			var jsonStr = result.data;
			var status = result.status;
			if(status == 0){
				whole_resData = JSON.parse(jsonStr);
				showSuperposition(id,returnColumn,superpositionFlag,labelX,labelY,color,labelAlign);
			}else{
				loadingFunc(id, false);
			}
		}
	});
}

/**
 * @note 展示地面填图类数据
 * @author 吴义迪
 * @create_time 2018-01-16
 */
function showSuperposition(id,returnColumn,superpositionFlag,labelX,labelY,color,labelAlign){
	if(parseInt(whole_resData.rowCount)>0){
		var returnColumnArr=returnColumn.split(",");
		var columnObj={};
		for(var i=0;i<returnColumnArr.length;i++){
			columnObj["column"+i]=returnColumnArr[i];
		}
		
		var layers = Global.common.map.getLayersByName("layer_"+id);
		if(layers.length <= 0){
			layers.push(new SuperMap.Layer.Vector("layer_"+id));
			Global.common.map.addLayer(layers[0]);
			Global.common.selectFeatureLayers.push(layers[0]);
			Global.common.selectFeature.setLayer(Global.common.selectFeatureLayers);
		}else{
			var ps = [];
			for(var i=0; i<layers[0].features.length; i++){
				for(var j=0; j<superpositionFlag.length; j++){
					if(layers[0].features[i].info.superpositionFlag == superpositionFlag[j]){
						ps.push(layers[0].features[i]);
					}
				}
			}
			layers[0].removeFeatures(ps);
		}
		var fs = [];
		//站点控制
    	var stationTypeArray = $("#advancedQuery_stationShowType_"+id+">span[flag=1]");
		var stationParamArray = [];
		for(var i=0; i<stationTypeArray.length; i++){
			stationParamArray.push(stationTypeArray[i].attributes.param.nodeValue);
		}
		for(var i=0;i<whole_resData.DS.length;i++){
			var obj=whole_resData.DS[i];
			for(var j=0;j<superpositionFlag.length;j++){
				//缺测值匹配
				if(superpositionFlag[j] != "CLO_Cov" && (obj[superpositionFlag[j]] == "" || (!isNaN(obj[superpositionFlag[j]]) && parseInt(obj[superpositionFlag[j]]) > 900000))){
					continue;
				}
				
				var station= new SuperMap.Geometry.Point(obj[columnObj["column2"]],obj[columnObj["column3"]]);
		    	var stationFeatureVector = new SuperMap.Feature.Vector(station);
		    	stationFeatureVector.info={};
		    	stationFeatureVector.info.layerId = id;
		    	stationFeatureVector.info.superpositionFlag = superpositionFlag[j];
		    	stationFeatureVector.info.returnColumnArr = returnColumnArr;
		    	for(var p=0; p<returnColumnArr.length; p++){
		    		stationFeatureVector.info[columnObj["column"+p]]=obj[columnObj["column"+p]];
		    	}
		    	stationFeatureVector.info["WIN_D_Avg_2mi"] = obj["WIN_D_Avg_2mi"];
		    	stationFeatureVector.info["TEM_ChANGE_24h"] = obj["TEM_ChANGE_24h"];
		    	stationFeatureVector.info["PRS_Change_24h"] = obj["PRS_Change_24h"];
		    	stationFeatureVector.info["TEM"] = obj["TEM"];
		    	stationFeatureVector.info["PRS_Sea"] = obj["PRS_Sea"];
		    	stationFeatureVector.info["WEP_Now"] = obj["WEP_Now"];
		    	stationFeatureVector.info["CLO_Cov"] = obj["CLO_Cov"];
		    	stationFeatureVector.info["WIN_S_Avg_2mi"] = obj["WIN_S_Avg_2mi"];
		    	stationFeatureVector.info["PRS_Change_3h"] = obj["PRS_Change_3h"];
		    	stationFeatureVector.info["VIS"] = obj["VIS"];
		    	stationFeatureVector.info["WEP_Past_1"] = obj["WEP_Past_1"];
		    	stationFeatureVector.info["WEP_Past_2"] = obj["WEP_Past_2"];
		    	stationFeatureVector.info["DPT"] = obj["DPT"];
		    	stationFeatureVector.info["CLO_Height_LoM"] = obj["CLO_Height_LoM"];
		    	stationFeatureVector.info["CLO_Cov_Low"] = obj["CLO_Cov_Low"];
		    	stationFeatureVector.info["PRE_6h"] = obj["PRE_6h"];
		    	if(superpositionFlag[j] == "WIN_S_Avg_2mi"){
		    		//根据风速风向返回不同图片
		    		var imgUrl=getImgUrlByDM(obj[superpositionFlag[j]]);
		    		stationFeatureVector.style = {
							graphic: true,
							externalGraphic: imgUrl,
							rotation:obj["WIN_D_Avg_2mi"],
							graphicWidth: 18,
							graphicHeight: 30,
							graphicXOffset: Number(labelX[j]),
							graphicYOffset: Number(labelY[j])
					};
		    	}else if(superpositionFlag[j] == "WEP_Now"){
		    		var imgUrl= "resources/images/currWeather/current" + obj[superpositionFlag[j]] + ".png";
		    		stationFeatureVector.style = {
							graphic: true,
							externalGraphic: imgUrl,
							graphicWidth: 14,
							graphicHeight: 14,
							graphicXOffset: Number(labelX[j]),
							graphicYOffset: Number(labelY[j])
					};
		    	}else if(superpositionFlag[j] == "WEP_Past_1" || superpositionFlag == "WEP_Past_2"){
		    		var imgUrl= "resources/images/lastWeather/last" + obj[superpositionFlag[j]] + ".png";
		    		stationFeatureVector.style = {
							graphic: true,
							externalGraphic: imgUrl,
							graphicWidth: 14,
							graphicHeight: 14,
							graphicXOffset: Number(labelX[j]),
							graphicYOffset: Number(labelY[j])
					};
		    	}else if(superpositionFlag[j] == "CLO_Cov"){
		    		var imgFlag = "";
		    		if(obj[superpositionFlag[j]] == 0){
		    			imgFlag = "0";
		    		}else if(parseInt(obj[superpositionFlag[j]]) > 0 && parseInt(obj[superpositionFlag[j]]) <= 10){
		    			imgFlag = "1";
		    		}else if(parseInt(obj[superpositionFlag[j]]) > 10 && parseInt(obj[superpositionFlag[j]]) <= 30){
		    			imgFlag = "2";
		    		}else if(parseInt(obj[superpositionFlag[j]]) > 30 && parseInt(obj[superpositionFlag[j]]) <= 40){
		    			imgFlag = "3";
		    		}else if(parseInt(obj[superpositionFlag[j]]) > 40 && parseInt(obj[superpositionFlag[j]]) <= 50){
		    			imgFlag = "4";
		    		}else if(parseInt(obj[superpositionFlag[j]]) > 50 && parseInt(obj[superpositionFlag[j]]) <= 60){
		    			imgFlag = "5";
		    		}else if(parseInt(obj[superpositionFlag[j]]) > 60 && parseInt(obj[superpositionFlag[j]]) <= 80){
		    			imgFlag = "6";
		    		}else if(parseInt(obj[superpositionFlag[j]]) > 80 && parseInt(obj[superpositionFlag[j]]) <= 90){
		    			imgFlag = "7";
		    		}else if(parseInt(obj[superpositionFlag[j]]) > 90 && parseInt(obj[superpositionFlag[j]]) <= 100){
		    			imgFlag = "8";
		    		}else{
		    			imgFlag = "9";
		    		}
		    		var imgUrl= "resources/images/cloudAmount/cloud_" + imgFlag + ".png";
		    		stationFeatureVector.style = {
							graphic: true,
							externalGraphic: imgUrl,
							graphicWidth: 14,
							graphicHeight: 14
					};
		    	}else{
		    		stationFeatureVector.style={
	    	        	fillColor: "#006400",
	    	        	fillOpacity: 0,
	    	        	strokeColor:"black",
	    	        	strokeOpacity: 0,
	    	        	strokeWidth: 1,
	    	        	pointRadius:5,
	    	        	fontColor: color[j],
	    	        	fontWeight:"bold",
	    	    		fontFamily:"微软雅黑",
	    	    		fontSize:"13px",
	    	    		fontStyle:"italic",
	    	    		labelSelect:"true",
	    	    		labelXOffset: Number(labelX[j]),
	    	    		labelYOffset: Number(labelY[j]),
	    	    		labelAlign: labelAlign[j],
	    	    		label:obj[superpositionFlag[j]]
	            	};
		    	}
		    	var stationType = "";
		    	if(obj["Station_levl"] == "11" || obj["Station_levl"] == "12" || obj["Station_levl"] == "13"){
		    		stationType = "station_gj";
		    	}else{
		    		stationType = "station_qy";
		    	}
		    	stationFeatureVector.info.stationType = stationType;
		    	if(stationParamArray.length > 0){
		    		for(var p=0; p<stationParamArray.length; p++){
			    		if(stationType == stationParamArray[p]){
			    			break;
			    		}
			    		if(p == stationParamArray.length - 1){
			    			stationFeatureVector.style.display = "none";
			    		}
			    	}
		    	}else{
		    		stationFeatureVector.style.display = "none";
		    	}
		    	fs.push(stationFeatureVector);
			}
		}
		layers[0].addFeatures(fs);
	}else{//无数据处理
		
	}
	loadingFunc(id, false);
}

/**
 * @note AreaCode 转化为 城市拼音
 * @author 陈靖宇
 * @create_time 2018-06-21
 */
function codeToName(code){
	if(code == "500000"){
		return "chongqingshi";
	}else if(code == "500103"){
		return "yuzhongqu";
	}else if(code == "500104"){
		return "dadukouqu";
	}else if(code == "500105"){
		return "jiangbeiqu";
	}else if(code == "500106"){
		return "shapingbaqu";
	}else if(code == "500107"){
		return "jiulongpoqu";
	}else if(code == "500108"){
		return "nananqu";
	}else if(code == "500109"){
		return "beibeiqu";
	}else if(code == "507509"){
		return "wanshengqu";
	}else if(code == "500111"){
		return "dazuqu";
	}else if(code == "500112"){
		return "yubeiqu";
	}else if(code == "500113"){
		return "bananqu";
	}else if(code == "500101"){
		return "wanzhouqu";
	}else if(code == "500102"){
		return "fulingqu";
	}else if(code == "500114"){
		return "qianjiangqu";
	}else if(code == "500115"){
		return "changshouqu";
	}else if(code == "500117"){
		return "hechuanqu";
	}else if(code == "500118"){
		return "yongchuanqu";
	}else if(code == "500116"){
		return "jiangjinqu";
	}else if(code == "500119"){
		return "nanchuanqu";
	}else if(code == "500110"){
		return "qijiangqu";
	}else if(code == "500223"){
		return "tongnanqu";
	}else if(code == "500224"){
		return "tongliangqu";
	}else if(code == "500111"){
		return "dazuqu";
	}else if(code == "500226"){
		return "rongchangqu";
	}else if(code == "500227"){
		return "bishanqu";
	}else if(code == "500232"){
		return "wulongxian";
	}else if(code == "500230"){
		return "fengduxian";
	}else if(code == "500229"){
		return "chengkouxian";
	}else if(code == "500228"){
		return "liangpingxian";
	}else if(code == "500234"){
		return "kaixian";
	}else if(code == "500238"){
		return "wuxixian";
	}else if(code == "500237"){
		return "wushanxian";
	}else if(code == "500236"){
		return "fengjiexian";
	}else if(code == "500235"){
		return "yunyangxian";
	}else if(code == "500233"){
		return "zhongxian";
	}else if(code == "500240"){
		return "shizhuxian";
	}else if(code == "500243"){
		return "pengshuixian";
	}else if(code == "500242"){
		return "youyangxian";
	}else if(code == "500241"){
		return "xiushanxian";
	}else if(code == "500231"){
		return "dianjiangxian";
	}
}